function checkEmail()
{
	var emailValue = document.getElementById("username").value;
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	if(emailValue.match(pattern))
	{
		document.getElementById("errorspan1").innerHTML = "";
		
		return true;
	}
	else
	{
		document.getElementById("errorspan1").innerHTML = " Please Enter Correct Email Address";
		
		
		return false;
	}
}

function emptyCheckForUserName() {
	var val = document.getElementById("username").value;
	if (val.length == 0 || val == "") {
		document.getElementById("errorspan1").innerHTML = "Please Enter The Username";
		return false;
	}

	return true;
}

function emptyCheckForPassword() {
	var val = document.getElementById("password").value;
	if (val.length == 0 || val == "") {
		document.getElementById("errorspan2").innerHTML = "Please Enter The Password";
		return false;
	}

	return true;
}
function checkName()
{
	var nameValue =document.getElementById("name").value;
	var pattern = /^[A-Za-z ]+$/;
	if(nameValue.match(pattern))
	{
		document.getElementById("errorspan4").innerHTML = "";
		
		return true;
	}
	else
	{
		document.getElementById("errorspan4").innerHTML = " Please Enter Valid Name";
		
		return false;
	}
}

function checkPassword()
{
	var pwd =document.getElementById("password").value;
	var confirmPwd = document.getElementById("conPassword").value;;
		if(pwd != confirmPwd)
		{
			document.getElementById("errorspan2").innerHTML = " Both password must be same ";
			document.getElementById("errorspan3").innerHTML = " Both password must be same ";
			
			return false;
		}
	else
	{
			document.getElementById("errorspan3").innerHTML = "";
			return true;
	}
}

function checkAge()
{
	var ageValue = document.getElementById("age").value;
	var pattern = /^[0-9]{2}$/;
	if(ageValue.match(pattern))
	{
		document.getElementById("errorspan5").innerHTML = "";
		
		return true;
	}
	else
	{
		document.getElementById("errorspan5").innerHTML = " Please Enter Valid Age";
		
		return false;
	}
}

function emptyCheckForConfirmPassword() {
	
	var val = document.getElementById("conPassword").value;
	if (val.length == 0 || val == "") {
		document.getElementById("errorspan3").innerHTML = "Please Enter The Confrim Password";
		return false;
	}

	return true;
}

function checkForEmpty() {
	
	var valid = true;
	if (!emptyCheckForUserName()) {
				valid = false;
	}
	else if(!checkEmail())
	{
		valid=false;
	}
		
	if (!emptyCheckForPassword()) {
		
		valid = false;
	}
	if (!emptyCheckForConfirmPassword() ) {
		
		valid = false;
	}
	else if(!checkPassword())
		{
			valid=false;
		}
	if(!checkName())
		{
			valid=false;
		}
	if(!checkAge())
	{
		valid=false;
	}

	return valid;

}


